package org.ppassantini.cham.core.action.menu;

import org.ppassantini.cham.core.business.security.dto.MenuDto;
import org.ppassantini.cham.core.business.secutity.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionSupport;

/**
 * @author ppassantini
 * 
 */
@Component
public class AddNewMenuAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3282122431489194304L;

	private String menu;
	private String mnemonic;

	@Autowired
	@Qualifier("menuService")
	private MenuService menuService;

	/**
	 * @return
	 */
	public String getMenu() {
		return menu;
	}

	/**
	 * @param menu
	 */
	public void setMenu(String menu) {
		this.menu = menu;
	}

	/**
	 * @return
	 */
	public String getMnemonic() {
		return mnemonic;
	}

	/**
	 * @param mnemonic
	 */
	public void setMnemonic(String mnemonic) {
		this.mnemonic = mnemonic;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() {
		MenuDto menuDto = new MenuDto();
		menuDto.setDescription(menu);
		menuDto.setMnemonic(mnemonic);

		menuService.addNewMenu(menuDto);

		return "success";
	}

}
